<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<title>title</title>
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../css/aui.css" />
	<link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
	<link rel="stylesheet" type="text/css" href="../css/icons.css" />
	<script src="../script/jquery-1.9.1.min.js"></script>
	<script src="../script/bootstrap.min.js"></script>
	<style>
		.table tr:first-child {
			background: url(static/img/tableheader-bg.gif) no-repeat left top;
			background-color: #DCE9F2;
			border-top: 1px solid #CBD6DE;
			border-bottom: 1px solid #ADBECB;
			color: #467aa7;
			font-size: 13px;
			font-weight: bold;
		}

		.table {
			margin-bottom: 15px;
			width: 100%;
			border-collapse: collapse;
			font-size: 13px;
			margin-bottom: 15px;
			width: 100%;
			border-collapse: collapse;
		}

		.table td {
			height: 40px;
			text-align: center;
			border: 1px solid #CBD6DE;
			padding: 0;
			margin: 0;
			vertical-align: middle !important;
		}

		body {
			height: auto !important;
		}
	</style>
</head>

<body>
	<header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
		<a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
			<span class="aui-iconfont aui-icon-left"></span>
		</a>
		<div class="aui-title" id="title">
			容器维修
		</div>
	</header>
	<div class="aui-content" style="margin-top:50px;">
		<div class="aui-form">
			<div class="aui-content aui-margin-b-15">
				<ul class="aui-list aui-form-list" style="font-size: 14px;">
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="font-size: 14px;">容器条码</div>
							<input type="text" class="aui-input" placeholder="请 扫描/输入 容器条码"
								style="width: 80%;font-size: 14px;" id="ctBarcode">
							<i class="aui-input-addon aui-iconfont aui-icon-scan " style="font-size: 1.6rem"
								onclick="toScanner();"></i>
						</div>
					</li>
					<li class="aui-list-item" style="background-color: rgb(187, 185, 185);">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="font-size: 14px;">任务单号</div>
							<div class="aui-list-item-input">
								<input type="text" class="aui-input" placeholder="" style="width: 80%;font-size: 14px;"
									id="taskCode" readonly>
							</div>
						</div>
					</li>
				</ul>
			</div>
			<ul id="myTab" class="nav nav-tabs" style="background-color: #F4F4F4;font-size: 13px;">
				<li class="active" style="width: 100%;text-align:center;"> <a href="#item" data-toggle="tab">异常项 </a>

				</li>

			</ul>
			<div id="myTabContent" class="tab-content">
				<div class="tab-pane fade in active" id="item">
					<div style="background-color:white; height: 100%;width: 100%;">
						<table id="chkItemTable" class="table" style="width:200%;">
							<thead id="chkItemTableHead">
							</thead>
						</table>
						<div class="aui-content">
							<div class="aui-btn aui-btn-info" onclick="doSave()" style="width: 100%;height: 100%;">
								<span class="aui-iconfont" style="font-size: 20px;">维修完成</span>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/hammer.min.js"></script>
<script type="text/javascript" src="../script/clickThrottle.js"></script>
<script>
	var taskCode = "";
	var itemIds = "";
	var itemCodes = "";
	var itemNames = "";
	var itemValues = "";
	var sysidList = "";
	var josnList = [];
	var delItemIds = "";
	var str = "";
	var strHC = "";
	var strYQ = "";
	//检测维修耗材参数
	var HCId = "";
	var mrlGid = "";
	var mrlCode = "";
	var mrlName = "";
	var mrlExName = "";
	var qty = "";
	var measureName = "";
	var consumeType = "";
	var remark = "";
	var josnHCList = [];
	var delHCIds = "";

	//检测维修耗材仪器
	var YqId = "";
	var mrlYqGid = "";
	var mrlYqCode = "";
	var mrlYqName = "";
	var remarkYq = "";
	var josnYqList = [];
	var delYqIds = "";

	var YqIds = "";
	var templateId = ""
	var uiMediaScanner = null;
	var imageFilter = null;
	var imageBrowser = null;

	var citemresult = "";
	var citemList = []

	var taskSysid = ""
	apiready = function () {
		$("#ctBarcode").focus();
		idSelector = "ctBarcode";
		// 引入多选模块
		uiMediaScanner = api.require('UIMediaScanner');
		// 引入过滤压缩模块
		imageFilter = api.require("imageFilter");
		// 引入图片浏览模块
		imageBrowser = api.require('imageBrowser');

	}


	function toScanner() {
		var moduleScanner = api.require('moduleScanner');
		var params = {
			top: 150,//扫描窗口的上边距
			width: 250,//扫描窗口的宽
			height: 250,//扫描窗口的高
			useColor: false,//是否使用自己设定的颜色(startColor和endColor),
			//如果不使用设定的颜色就使用默认的那张网格图
			startColor: '#0F08C8FF',//渐变起始颜色
			endColor: '#7F08C8FF',//渐变结束颜色
			animTime: 2200,//扫描动画时间,单位为毫秒
		};
		moduleScanner.toScannerActivityForResult(params, function (ret, err) {
			if (idSelector == 'ctBarcode') {
				//容器条码
				$("#ctBarcode").val(ret);
				chkCtBarcode(ret);
			}
		});
	}
	$("#ctBarcode").on('keypress', function (e) {
		var keycode = e.keyCode;
		var tm = $(this).val();
		if (keycode == '13') {
			if (tm != null && tm != "" && tm != undefined) {
				$("#ctBarcode").val(tm);
				chkCtBarcode(tm);
			}
		}
	});

	function doSave() {

		var ctBarcode = document.getElementById("ctBarcode").value;

		if (ctBarcode == "" || ctBarcode == null || ctBarcode == undefined) {
			api.toast({
				msg: '容器条码不能为空！',
				duration: 3000
			});
			return;
		}
		//提交数据到服务端
		doSubmit();

	}
	function doSubmit(repairFlag) {
		var ctBarcode = document.getElementById("ctBarcode").value;
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/saveContainerRepair";
		var un = localStorage.getItem('un');

		var params = new Object();
		params.url = url;
		params.method = 'post';
		params.dataType = 'json';
		params.returnAll = 'false';
		params.timeout = 60;

		api.showProgress({
			title: '保存中...',
		});

		var data = {
			values: {
				un: un,
				ctBarcode: ctBarcode,
				sysid: taskSysid,
			}
		};

		api.ajax({
			url: url,
			method: 'post',
			dataType: 'json',
			timeout: 300,
			returnAll: false,
			data: data
		}, function (ret, err) {
			if (ret) {
				var data = JSON.stringify(ret);
				var myobj = eval("(" + data + ")");
				//成功
				
				if (myobj.code == '0') {

					api.hideProgress();
					api.toast({
						msg: "保存成功",
						duration: 3000
					});
					//清空设备扫码框				
					$("#ctBarcode").val("").focus();
					$("#taskCode").val("")
					//清空点检项表格
					$("#chkItemTableHead").children().remove();
				} else if (myobj.code == '1') {

					api.hideProgress();
					api.toast({
						msg: myobj.message,
						duration: 3000
					});
				}
			} else {

				api.hideProgress();
				alert(JSON.stringify(err));
			}
		});
	}

	function chkCtBarcode() {
		var sm = $("#ctBarcode").val();
		var un = localStorage.getItem('un');
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/searchContainerRepair";
		var data = {
			values: {
				sm: sm,
				un: un
			}
		};
		api.ajax({
			url: url,
			method: 'post',
			dataType: 'json',
			timeout: 300,
			returnAll: false,
			data: data
		}, function (ret, err) {
			if (ret) {
				var data = JSON.stringify(ret);
				var myobj = eval("(" + data + ")");
				//返回成功
				if (myobj.code == '0') {
					itemIds = "";
					itemCodes = "";
					itemNames = "";
					itemValues = "";
					sysidList = "";
					josnList = [];
					var list = myobj.list;

					taskSysid = myobj.sysid
					$("#taskCode").val(myobj.taskCode);
					var html = "";
					var html1 = "";
					html1 += "<tr id='tr1' color: #467aa7;>";
					html1 += "<td algin='center'>序号</td>";
					html1 += "<td algin='center'>问题描述</td>";

					$api.html($api.byId("chkItemTableHead"), html1);
					str = "";
					if (list != undefined) {
						//遍历
						for (var i = 0; i < list.length; i++) {
							var itemName = list[i].chkItemName;

							str +=
								"<tr>"
								+ "<td width='15%' >" + "" + "<input type='text' readonly value='" + (i + 1) + "'></td> "
								+ "<td algin='center'>" + itemName + "</td>"
								+ "</tr>";
						}
					}
					$("#chkItemTableHead").append(str);
				} else if (myobj.code == "1") {
					$("#ctBarcode").val("");
					$("#ctBarcode").select();
					idSelector = "ctBarcode";
					api.toast({
						msg: myobj.message,
						duration: 3000
					});
				}
				api.hideProgress();
			} else {
				$("#ctBarcode").val("");
				$("#ctBarcode").select();
				idSelector = "ctBarcode";
				api.hideProgress();
				alert("连接超时，请耐心等待");
			}
		});
	}

	//返回按钮
	function closeWin() {
		api.closeWin({});
	}
</script>

</html>